package com.smedi.ismedi.progress.core.port.adapter.service.impl;

import com.smedi.ismedi.authoritymanagement.api.dto.response.RoleBasicResponse;
import com.smedi.ismedi.authoritymanagement.api.feign.RemoteAuthorityRoleManagementFeignApi;
import com.smedi.ismedi.progress.core.port.adapter.service.AuthorityRoleManagementRemoteApiService;
import com.smedi.ismedi.web.starter.util.DozerUtil;
import lombok.AllArgsConstructor;
import org.springframework.stereotype.Service;

import java.util.List;

/**
 * 角色权限接口实现类
 *
 * @author xienannan
 * @date 2021/08/28
 */
@Service
@AllArgsConstructor
public class AuthorityRoleManagementRemoteApiServiceImpl implements AuthorityRoleManagementRemoteApiService {
    private final RemoteAuthorityRoleManagementFeignApi remoteAuthorityRoleManagementFeignApi;

    private final DozerUtil dozerUtil;

    @Override
    public List<Long> getAllPersonIdsByRoleName(String roleName) {
        List<RoleBasicResponse> roleBasicResponseList = remoteAuthorityRoleManagementFeignApi.getQueryAllPersonIdsByRoleId(roleName, false, true).getData();
        if (roleBasicResponseList.size() > 0) {
            List<Long> longList =  roleBasicResponseList.get(0).getRoleOwnerPersonIds();
            if(longList !=null && longList.size()>0){
                return longList;
            }
        }
        return null;
    }
}
